
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BodySoundSimulator.CaseData;
using System.IO;
using System.Collections.ObjectModel;
using BodySoundSimulator.Recording;
using BodySoundSimulator.CommonElements;
using BodySoundSimulator.Training;
using BodySoundSimulator;
using BodySoundSimulator.AbsoluteMapData;

namespace BodySoundSimulator
{
    public partial class mainframe : Form, IApplicationServices
    {
        #region Fields
        Dictionary<string, CaseInformation> existingCases;
        AbsoluteBodyFeatures absoluteFeatures;
        #endregion

        #region Constructors
        public mainframe(ApplicationMode mode)
        {
            InitializeComponent();
			this.existingCases = SimulatorFileManager.GetExistingCaseInformation();
			this.absoluteFeatures = AbsoluteBodyFeaturesDataManipulator.LoadAbsoluteBodyFeatureData();

			switch (mode)
			{
				case ApplicationMode.None:
					break;
				case ApplicationMode.Practicing:
					//load practicing control
					this.pnlMain.Controls.Add(new Trainer(this));
					break;
				case ApplicationMode.Recording:
					//load recording control
					this.pnlMain.Controls.Add(new Recorder(this));
					break;
				case ApplicationMode.Testing:
					//load testing control
					break;
			}
        }
        #endregion

        #region IApplicationServices Members

        public Dictionary<string, CaseInformation> ExistingCases
        {
            get 
            {
                return this.existingCases;
            }
        }

        public AbsoluteBodyFeatures AbsoluteFeatures
        {
            get 
            {
                return this.absoluteFeatures;
            }
        }

        public void ExistingCaseListChanged()
        {
            this.existingCases = SimulatorFileManager.GetExistingCaseInformation();
        }

		public event EventHandler ApplicationCloseing;

        #endregion

		#region UI event handlers
		private void mainframe_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.ApplicationCloseing != null)
			{
				this.Dispose();
				this.ApplicationCloseing(this, EventArgs.Empty);
			}
		}
		#endregion
	}
}